<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <title>盆栽商店</title>
    <meta content="width=device-width, initial-scale=1.0" name="viewport">
    <meta content="eCommerce HTML Template Free Download" name="keywords">
    <meta content="eCommerce HTML Template Free Download" name="description">

    <!-- Favicon -->
    <link href="img/favicon.ico" rel="icon">

    <!-- Google Fonts -->
    <link href="https://fonts.googleapis.com/css?family=Open+Sans:300,400|Source+Code+Pro:700,900&display=swap"
          rel="stylesheet">

    <!-- CSS Libraries -->
    <link href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css" rel="stylesheet">
    <link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.10.0/css/all.min.css" rel="stylesheet">
    <link href="lib/slick/slick.css" rel="stylesheet">
    <link href="lib/slick/slick-theme.css" rel="stylesheet">

    <!-- Template Stylesheet -->
    <link href="css/cart.css" rel="stylesheet">
    <link href="css/autoComplete.css" rel="stylesheet" type="text/css">
</head>

<body>
<!-- Top bar Start -->
<div class="top-bar">
    <div class="container-fluid">
        <div class="row">
            <div class="col-sm-6">
                <i class="fa fa-envelope"></i>
                CSU
            </div>
            <div class="col-sm-6">
                <i class="fa fa-phone-alt"></i>
                400-114514
            </div>
        </div>
    </div>
</div>
<!-- Top bar End -->

<!-- Nav Bar Start -->
<div class="nav">
    <div class="container-fluid">
        <nav class="navbar navbar-expand-md bg-dark navbar-dark">
            <a href="#" class="navbar-brand">MENU</a>
            <button type="button" class="navbar-toggler" data-toggle="collapse" data-target="#navbarCollapse">
                <span class="navbar-toggler-icon"></span>
            </button>

            <div class="collapse navbar-collapse justify-content-between" id="navbarCollapse">
                <div class="navbar-nav mr-auto">
                    <a href="welcome" class="nav-item nav-link active">主页</a>
                    <a href="category?categoryId=cat" class="nav-item nav-link" id="cat">花本植物</a>
                    <a href="category?categoryId=dog" class="nav-item nav-link" id="dog">木本植物</a>
                    <a href="category?categoryId=bird" class="nav-item nav-link" id="bird">草本植物</a>
                    <a href="category?categoryId=pokemon" class="nav-item nav-link" id="pokemon">多肉植物</a>
                    <a href="category?categoryId=bugCat" class="nav-item nav-link" id="bugCat">景观植物</a>
                </div>
                <div class="navbar-nav ml-auto">
                    <a href="cart" class="nav-item nav-link">购物车</a>
                    <!--用户是否登录-->
                    <c:if test="${sessionScope.username != null}">
                        <a href="space" class="nav-item nav-link">用户中心</a>
                    </c:if>
                    <c:if test="${sessionScope.username == null}">
                        <a href="login" class="nav-item nav-link">欢迎登录</a>
                    </c:if>
                </div>
            </div>
        </nav>
    </div>
</div>
<!-- Nav Bar End -->

<!-- Bottom Bar Start -->
<div class="bottom-bar">
    <div class="container-fluid">
        <div class="row align-items-center">
            <div class="col-md-3">
                <div class="logo">
                    <a href="welcome">
                        <img src="image/mainPage/logo.png" alt="Logo">
                    </a>
                </div>
            </div>
            <div class="col-md-6">
                <form action="Search" method="post">
                    <div class="search">
                        <input type="text" placeholder="搜索想要的盆栽吧" name="searchName" id="searchName">
                        <button><i class="fa fa-search"></i></button>
                    </div>
                    <!--自动补全-->
                    <div id="autoComplete" class="searchComp">
                        <li id="autoCompleteLi">
                        </li>
                    </div>
                </form>
            </div>
            <div class="col-md-3">
                <div class="user">
                    <a href="cart" class="btn cart">
                        <i class="fa fa-shopping-cart"></i>
                        <span id="cartNumberSpan">(0)</span>
                    </a>
                </div>
            </div>
        </div>
    </div>
</div>
<!-- Bottom Bar End -->


<!-- Cart Start -->
<div class="cart-page">
    <div class="container-fluid">
        <form action="order">
            <div class="row hs">
                <c:if test="${sessionScope.username!=null}">
                    <div class="col-lg-8">
                        <div class="cart-page-inner">
                            <div class="table-responsive">
                                <table class="table table-bordered">
                                    <thead class="thead-dark">
                                    <tr>
                                        <th><span>选则<input type="checkbox" checked="checked" class="choose_all"></span>
                                        </th>
                                        <th>商品</th>
                                        <th>价格</th>
                                        <th>数量</th>
                                        <th>总价</th>
                                        <th>移除</th>
                                    </tr>
                                    </thead>
                                    <tbody class="align-middle">
                                    <c:forEach var="cartItem" items="${sessionScope.cartItemList}">
                                        <tr class="column" id="row${cartItem.item.itemId}">
                                            <td>
                                                <input type="checkbox" name="${cartItem.item.itemId}" checked="checked"
                                                       id="${cartItem.item.itemId}" class="choose">
                                            </td>
                                            <td>
                                                <div class="img">
                                                    <a href="Item?productId=${cartItem.item.productId}&categoryId=${cartItem.item.categoryId}">
                                                        <img src="${cartItem.item.description}" alt="Image">
                                                    </a>
                                                    <a href=Item?productId=${cartItem.item.productId}&categoryId=${cartItem.item.categoryId}" style="color: black">
                                                            ${cartItem.item.name}
                                                    </a>
                                                </div>
                                            </td>
                                            <td><b id="price${cartItem.item.itemId}" class="unit">￥${cartItem.price}</b>
                                            </td>
                                            <td>
                                                <div class="qty">
                                                    <button type="button" class="btn-minus"
                                                            id="${cartItem.item.itemId}"><i class="fa fa-minus"></i>
                                                    </button>
                                                    <label>
                                                        <input type="text" id="ip${cartItem.item.itemId}"
                                                               name="quantity"
                                                               class="unum"
                                                               readonly="readonly"
                                                               value=${cartItem.quantity}>
                                                    </label>
                                                    <button type="button" class="btn-plus" id="${cartItem.item.itemId}">
                                                        <i class="fa fa-plus"></i></button>
                                                </div>
                                            </td>
                                            <td><b id="up${cartItem.item.itemId}" class="u-price"></b></td>
                                            <td><a href="#" id="del${cartItem.item.itemId}" class="btn-del"><i
                                                    class="fa fa-trash"></i></a></td>
                                        </tr>
                                    </c:forEach>
                                    </tbody>
                                </table>
                            </div>
                        </div>
                    </div>
                    <div class="col-lg-4 father" style="position: relative;">
                        <div class="cart-page-inner floating">
                            <div class="row">
                                <div class="col-md-12">
                                    <div class="coupon">
                                        <input type="text" id="disId" placeholder="优惠码">
                                        <button type="button" id="disBtn">确认使用</button>
                                    </div>
                                </div>
                                <div class="col-md-12">
                                    <div class="cart-summary">
                                        <div class="cart-content">
                                            <h1>价格核算</h1>
                                            <p>总价<span class="t-price"></span></p>
                                            <p>优惠<span class="discount">￥0</span></p>
                                            <p>数量<span class="t-number"></span></p>
                                            <h2>合计<span class="l-price"></span></h2>
                                        </div>
                                        <div class="cart-btn">
                                            <input type="button" value="移除选中" class="del_check">
                                            <input type="submit" value="去支付" id="pay">
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </c:if>
                <c:if test="${sessionScope.username == null}">
                    <div class="col-lg-8" style="height: 100px">
                        <a class="test" href="/petstore/login" style="font-size: 50px;">请先登录再来查看购物车哦</a>
                    </div>
                </c:if>
            </div>
        </form>
    </div>
</div>
<!-- Cart End -->

<!-- Call to Action Start -->
<div class="call-to-action">
    <div class="container-fluid">
        <div class="row align-items-center">
            <div class="col-md-6">
                <h1>遇到问题?立即联系我们</h1>
            </div>
            <div class="col-md-6">
                <a href="tel:0123456789">400-114514</a>
            </div>
        </div>
    </div>
</div>
<!-- Call to Action End -->


<!-- Footer Bottom Start -->
<div class="footer-bottom">
    <div class="container">
        <div class="row">
            <div class="col-md-6 copyright">
                <p>Supported By &copy; <a href="https://csu.edu.cn">CSU</a>. </p>
            </div>

            <div class="col-md-6 template-by">
                <p>Powered By <a href="https://csu.edu.cn">CSUer</a></p>
            </div>
        </div>
    </div>
</div>
<!-- Footer Bottom End -->

<!-- Back to Top -->
<a href="#" class="back-to-top"><i class="fa fa-chevron-up"></i></a>

<!-- JavaScript Libraries -->
<script src="https://code.jquery.com/jquery-3.4.1.min.js"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/js/bootstrap.bundle.min.js"></script>
<script src="lib/easing/easing.min.js"></script>
<script src="lib/slick/slick.min.js"></script>

<!-- Template Javascript -->
<script src="javascripts/index.js"></script>
<script src="javascripts/cartNum.js"></script>
<script src="javascripts/autoComplete.js"></script>
<script src="javascripts/cart.js"></script>
</body>
</html>